﻿#include "panel.h"
#include <QPainter>
#include <QDebug>
Panel::Panel(QWidget *parent)
    : QWidget{parent}
{}

void Panel::setImg(const QImage &in_img)
{
    if(m_img == in_img)
        return;
    m_img = in_img;
    update();
}

void Panel::paintEvent(QPaintEvent *event)
{
    if(m_img.isNull())
        return;

    QPainter painter(this);
    int rectWidth = this->width();
    int rectHeight = this->height();
    QImage tmpImg = m_img.scaled(rectWidth,rectHeight,Qt::KeepAspectRatio,Qt::SmoothTransformation);
    painter.drawImage(rect(),tmpImg);
}
